package org.infinitest.intellij;

import org.junit.Test;
import org.infinitest.TestEvent;
import org.jmock.Expectations;
import org.jmock.Mockery;

@SuppressWarnings({"ThrowableInstanceNeverThrown"})
public class WhenTestErrors {
  private InfinitestAnnotator annotator;
  private Mockery mockery = new Mockery();

  @Test
  public void shouldAnnotateEvent() {
    final TestEvent error = new TestEvent(TestEvent.TestState.METHOD_ERROR, "message", "test", "method",
            new Exception());

    annotator = mockery.mock(InfinitestAnnotator.class);
    mockery.checking(new Expectations() {
      {
        one(annotator).annotate(error);
      }
    });

    new InfinitestTestStatusListener(annotator).testMethodError(error);

    mockery.assertIsSatisfied();
  }
}
